/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplemetrosystem.view.bar;

import javax.swing.JMenuBar;
import simplemetrosystem.view.MetroFrame;
import simplemetrosystem.view.menu.EditMenu;
import simplemetrosystem.view.menu.FileMenu;
import simplemetrosystem.view.menu.HelpMenu;
import simplemetrosystem.view.menu.DisplayMenu;
import simplemetrosystem.view.menu.ModelMenu;

/**
 *
 * @author Eric Qian
 */
public class MetroMenuBar extends JMenuBar {

    private MetroFrame frame;
    private FileMenu file;
    private EditMenu edit;
    private ModelMenu cal;
    private DisplayMenu display;
    private HelpMenu help;
    private boolean model;

    /**
     * 
     * @param frame
     */
    public MetroMenuBar(MetroFrame frame) {
        super();
        this.frame = frame;
        model = false;
        this.add(getFileMenu());
        this.add(getEditMenu());
        this.add(getCalMenu());
        this.add(getDisMenu());
        this.add(getHelpMenu());
    }

    /**
     * 
     * @return
     */
    public FileMenu getFileMenu() {
        if (file == null) {
            file = new FileMenu(frame);
        }
        return file;
    }

    /**
     * 
     * @return
     */
    public EditMenu getEditMenu() {
        if (edit == null) {
            edit = new EditMenu(frame);
        }
        return edit;
    }

    /**
     * 
     * @return
     */
    public ModelMenu getCalMenu() {
        if (cal == null) {
            cal = new ModelMenu(frame);
        }
        return cal;
    }

    /**
     * 
     * @return
     */
    public DisplayMenu getDisMenu() {
        if (display == null) {
            display = new DisplayMenu(frame);
        }
        return display;
    }

    @Override
    public HelpMenu getHelpMenu() {
        if (help == null) {
            help = new HelpMenu(frame);
        }
        return help;
    }

    public void setModel(boolean model) {
        if (this.model != model) {
            this.model = model;
            if (model) {
                display.setEnabled(false);
                edit.setEnabled(false);
                cal.setModel(model);
            } else {
                display.setEnabled(true);
                edit.setEnabled(true);
                cal.setModel(model);
            }
        }
    }
}
